<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" %>
<%@ page import="com.edu.service.*"%>
<%@ page import="com.edu.service.impl.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.edu.entity.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="x" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/class.css">
</head>
<script type="text/javascript" src="js/jquery-3.7.1.js"></script>
<body>
<form id='form' method="post" action="ConServlet">
  		<div id="myid1">
 			<p><img src="image/2.png"><span>学生管理系统</span></p><br>
		 <ul>
		      <li><img src="image/3.png"><a href="class.jsp">班级管理</a></li><br><br><br>
		      <li><img src="image/4.png"><a href="teacher.jsp">老师管理</a></li><br><br><br>
		      <li><img src="image/5.png"><a href="student.jsp" >学生管理</a></li><br><br><br>
		      <li><img src="image/6.png"><a href="grade.jsp">成绩管理</a></li><br><br><br>
		      <li><img src="image/7.png"><a href="updatePass.jsp">修改密码</a></li><br><br><br>
		      <li><img src="image/8.png"><a href="log.jsp">退出登录</a></li><br><br><br>
		   </ul>  
</div>
<div id="myWork">
    <div id="myClass1">
             <p>
                 <label for="#myLabel">班级名称: </label>
                 <input type="text" id="myLabel" placeholder="搜索班级名称" name="cName">
                 <input type="button" value="搜索" id="mysouso" onclick="showAction('ScNameServlet')">
                 <input type="button" value="新增" id="myAdd" onclick="showAction('doAdd.jsp')">
            </p>
    </div>
    <table>
        <tr>
           <td>班级序号</td>
           <td>班级名称</td>
           <td>班级编号</td>
           <td>操作</td>
        </tr>
        <%
	        request.setCharacterEncoding("UTF-8");
	        Object obj=request.getAttribute("list");
	        if(obj==null){
	        	 UserService userservice=new UserServiceimpl();
	        	 List<Cl> clas=userservice.Select();
	             request.setAttribute("list", clas);
	        }
        %>
        <x:forEach items="${requestScope.list }" var="clas" varStatus="status">
           <x:choose>
              <x:when test="${status.count%2==0 }">
                  <tr style="background-color:#ccc;">
                   <td>${clas.cId}</td>
		           <td>${clas.cName}</td>
		           <td>${clas.cNum }</td>
		           <td>
		                 <a href="doUpdate.jsp?cId=${clas.cId}&cName=${clas.cName}&cNum=${clas.cNum }" id="myBj">编辑</a>
		                 <a href="DeleteServlet?cId=${clas.cId}" id="myDel">删除</a>
		           </td>
	             </tr>
              </x:when>
              <x:otherwise>
                   <tr>
                   <td>${clas.cId}</td>
		           <td>${clas.cName}</td>
		           <td>${clas.cNum }</td>
		           <td>
		                 <a href="doUpdate.jsp?cId=${clas.cId}&cName=${clas.cName}&cNum=${clas.cNum }" id="myBj">编辑</a>
		                 <a href="DeleteServlet?uid=${clas.cId}" id="myDel">删除</a>
		           </td>
	             </tr>
              </x:otherwise>
           </x:choose>            
        </x:forEach>
    </table>
</div>
<input type="hidden" id="uid" value="" name="uid">
</form>
</body>
<script>
     function $(id){
    	 return document.getElementById(id);
     }
    function showAction(url){
    	$("form").action=url;
    	$("form").submit();
    }
</script>
</html>